/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.lm.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Robson Motta
 */
@Entity
@Table(name = "ctrl_objeto_acesso")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CtrlObjetoAcesso.findAll", query = "SELECT c FROM CtrlObjetoAcesso c"),
    @NamedQuery(name = "CtrlObjetoAcesso.findByKey", query = "SELECT c FROM CtrlObjetoAcesso c WHERE c.ctrlObjetoAcessoPK.idObjAutoriz = :idObjAutoriz" 
                                                                                            + " AND c.ctrlObjetoAcessoPK.idModulo = :idModulo"
                                                                                            + " AND c.ctrlObjetoAcessoPK.numSeqObj = :numSeqObj")})
public class CtrlObjetoAcesso implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CtrlObjetoAcessoPK ctrlObjetoAcessoPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "nom_obj_01")
    private String nomObj01;
    @Size(max = 255)
    @Column(name = "nom_obj_02")
    private String nomObj02;
    @Size(max = 255)
    @Column(name = "ext_objs")
    private String extObjs;
    
    @JoinColumn(name = "id_modulo", referencedColumnName = "id_modulo", insertable = false, updatable = false)
    @ManyToOne(fetch = FetchType.LAZY, optional = false) //@ManyToOne(optional = false)
    private CtrlModulo ctrlModulo;

    public CtrlObjetoAcesso() {
    }

    public CtrlObjetoAcesso(CtrlObjetoAcessoPK ctrlObjetoAcessoPK) {
        this.ctrlObjetoAcessoPK = ctrlObjetoAcessoPK;
    }

    public CtrlObjetoAcesso(CtrlObjetoAcessoPK ctrlObjetoAcessoPK, String nomObj01) {
        this.ctrlObjetoAcessoPK = ctrlObjetoAcessoPK;
        this.nomObj01 = nomObj01;
    }

    public CtrlObjetoAcesso(int idObjAutoriz, int idModulo, int numSeqObj) {
        this.ctrlObjetoAcessoPK = new CtrlObjetoAcessoPK(idObjAutoriz, idModulo, numSeqObj);
    }

    public CtrlObjetoAcessoPK getCtrlObjetoAcessoPK() {
        return ctrlObjetoAcessoPK;
    }

    public void setCtrlObjetoAcessoPK(CtrlObjetoAcessoPK ctrlObjetoAcessoPK) {
        this.ctrlObjetoAcessoPK = ctrlObjetoAcessoPK;
    }

    public String getNomObj01() {
        return nomObj01;
    }

    public void setNomObj01(String nomObj01) {
        this.nomObj01 = nomObj01;
    }

    public String getNomObj02() {
        return nomObj02;
    }

    public void setNomObj02(String nomObj02) {
        this.nomObj02 = nomObj02;
    }

    public String getExtObjs() {
        return extObjs;
    }

    public void setExtObjs(String extObjs) {
        this.extObjs = extObjs;
    }

    public CtrlModulo getCtrlModulo() {
        return ctrlModulo;
    }

    public void setCtrlModulo(CtrlModulo ctrlModulo) {
        this.ctrlModulo = ctrlModulo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ctrlObjetoAcessoPK != null ? ctrlObjetoAcessoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CtrlObjetoAcesso)) {
            return false;
        }
        CtrlObjetoAcesso other = (CtrlObjetoAcesso) object;
        if ((this.ctrlObjetoAcessoPK == null && other.ctrlObjetoAcessoPK != null) || (this.ctrlObjetoAcessoPK != null && !this.ctrlObjetoAcessoPK.equals(other.ctrlObjetoAcessoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.lm.entity.CtrlObjetoAcesso[ ctrlObjetoAcessoPK=" + ctrlObjetoAcessoPK + " ]";
    }
    
}
